pref(provider):增加强构造器#153
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Member
|
Collaborator
|
我看下来基本上没有什么大问题,对StreamEventType 与Payload都符合我预期要的,就是有两个问题:我需要一个文档表明你实现的字段类型以及暴露的接口;覆盖率这个问题不知道会不会影响到别人的pr。 |
Collaborator
Author
接口文档在issue#169 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
对
internal/provider层实施 StreamEvent 强类型迁移 Phase 1:引入Payload接口字段 + 4 个强类型 Payload 结构体 + 4 个构造器函数,同时通过兼容层保持 Runtime/TUI 零改动可运行。主要改动
internal/provider/types.goPayload interface{}字段;新增TextDeltaPayload、ToolCallStartPayload、ToolCallDeltaPayload、MessageDonePayload四种强类型;新增NewTextDeltaStreamEvent()/NewToolCallStartStreamEvent()/NewToolCallDeltaStreamEvent()/NewMessageDoneStreamEvent()四个构造器,构造器同步填充 Payload + 弃用扁平字段以实现向后兼容internal/provider/openai/openai.goemitTextDelta/emitToolCallStart/emitToolCallDelta/emitMessageDone)全部从裸StreamEvent{...}切换为构造器调用;emitToolCallDelta签名新增id参数补全 toolCallID;mergeToolCallDelta调用处传入call.ID;修复Driver()中局部变量与包名冲突(provider→p)internal/provider/openai/openai_test.goemitToolCallDelta新签名(补充id实参),更新断言覆盖新字段docs/phase2-runtime-migration.md预期收益
StreamEvent从扁平弱类型字段升级为强类型 Payload + 构造器强制模式,杜绝运行时字段错配风险emitToolCallDelta新增id参数,解决了此前 tool_call_delta 事件缺少 ToolCallID 的问题go build ./...),全量测试 18/18 包全绿 (go test ./...)